﻿using System.ComponentModel;
using System.Web.UI;
using System.Drawing.Design;
using System.Web.UI.WebControls;

namespace jQuery.WebControls.RocketDock
{
    /// <summary>
    /// Clase que hereda del Control Web Image
    /// </summary>            
    [TypeConverter(typeof(ExpandableObjectConverter))]    
    public class Icono : ImageButton
    {

        /// <summary>
        /// Genera la salida HTML al cargarse la página
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            string javascript = "";            
            if (HasEvents())
            {
                PostBackOptions pbo = new PostBackOptions(this);                
                javascript = "javascript:" + Page.ClientScript.GetPostBackEventReference(pbo);                
            }
            else if (PostBackUrl != string.Empty && PostBackUrl != "")
            {
                javascript = Page.ResolveClientUrl(PostBackUrl);
            }
            else
            {
                javascript = "#";
            }
            string html = "<a class=\"" + CssClass + "\" onmouseover=\"\" href=\"" + javascript + "\">" +
                "<img src=\"" + Page.ResolveUrl(ImageUrl) + "\" alt=\"" + AlternateText + "\" />" +
                "<span>" + ToolTip + "</span></a>";
            writer.Write(html);           
        }
    }
}
